#!/bin/bash

set -o pipefail -e
export PRELAUNCH_OUT="/export/bigdata/hadoop/logs/userlogs/application_1749212209307_0015/container_e16_1749212209307_0015_01_000002/prelaunch.out"
exec >"${PRELAUNCH_OUT}"
export PRELAUNCH_ERR="/export/bigdata/hadoop/logs/userlogs/application_1749212209307_0015/container_e16_1749212209307_0015_01_000002/prelaunch.err"
exec 2>"${PRELAUNCH_ERR}"
echo "Setting up env variables"
export JAVA_HOME=${JAVA_HOME:-"/usr"}
export HADOOP_COMMON_HOME=${HADOOP_COMMON_HOME:-"/export/bigdata/hadoop"}
export HADOOP_HDFS_HOME=${HADOOP_HDFS_HOME:-"/export/bigdata/hadoop"}
export HADOOP_CONF_DIR=${HADOOP_CONF_DIR:-"/export/bigdata/hadoop/etc/hadoop"}
export HADOOP_YARN_HOME=${HADOOP_YARN_HOME:-"/export/bigdata/hadoop"}
export HADOOP_HOME=${HADOOP_HOME:-"/export/bigdata/hadoop"}
export PATH=${PATH:-"/usr/local/bin:/usr/bin:/export/bigdata/hadoop/bin:/export/bigdata/hadoop/sbin:/usr/lib/jvm/jdk/bin"}
export LANG=${LANG:-"zh_CN.UTF-8"}
export HADOOP_TOKEN_FILE_LOCATION="/export/bigdata/hadoop/tmp/nm-local-dir/usercache/bigdata/appcache/application_1749212209307_0015/container_e16_1749212209307_0015_01_000002/container_tokens"
export CONTAINER_ID="container_e16_1749212209307_0015_01_000002"
export NM_PORT="9367"
export NM_HOST="hadoop0012"
export NM_HTTP_PORT="8042"
export LOCAL_DIRS="/export/bigdata/hadoop/tmp/nm-local-dir/usercache/bigdata/appcache/application_1749212209307_0015"
export LOCAL_USER_DIRS="/export/bigdata/hadoop/tmp/nm-local-dir/usercache/bigdata/"
export LOG_DIRS="/export/bigdata/hadoop/logs/userlogs/application_1749212209307_0015/container_e16_1749212209307_0015_01_000002"
export USER="bigdata"
export LOGNAME="bigdata"
export HOME="/home/"
export PWD="/export/bigdata/hadoop/tmp/nm-local-dir/usercache/bigdata/appcache/application_1749212209307_0015/container_e16_1749212209307_0015_01_000002"
export LOCALIZATION_COUNTERS="163727915,0,1,0,5495"
export JVM_PID="$$"
export NM_AUX_SERVICE_mapreduce_shuffle="AAA0+gAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="
export CLASSPATH="$CLASSPATH:$PWD/log4j.properties:$PWD:$HADOOP_CLIENT_CONF_DIR:$HADOOP_CONF_DIR:$JAVA_HOME/lib/tools.jar:$PWD/demo/:$PWD/demo/conf/:$PWD/demo/*:/export/bigdata/hadoop/etc/hadoop:/export/bigdata/hadoop/share/hadoop/common/lib/*:/export/bigdata/hadoop/share/hadoop/common/*:/export/bigdata/hadoop/share/hadoop/hdfs:/export/bigdata/hadoop/share/hadoop/hdfs/lib/*:/export/bigdata/hadoop/share/hadoop/hdfs/*:/export/bigdata/hadoop/share/hadoop/mapreduce/*:/export/bigdata/hadoop/share/hadoop/yarn:/export/bigdata/hadoop/share/hadoop/yarn/lib/*:/export/bigdata/hadoop/share/hadoop/yarn/*"
export MALLOC_ARENA_MAX="4"
echo "Setting up job resources"
ln -sf -- "/export/bigdata/hadoop/tmp/nm-local-dir/usercache/bigdata/filecache/10/yarn-client-test-1.0-SNAPSHOT.jar" "demo"
echo "Copying debugging information"
# Creating copy of launch script
cp "launch_container.sh" "/export/bigdata/hadoop/logs/userlogs/application_1749212209307_0015/container_e16_1749212209307_0015_01_000002/launch_container.sh"
chmod 640 "/export/bigdata/hadoop/logs/userlogs/application_1749212209307_0015/container_e16_1749212209307_0015_01_000002/launch_container.sh"
# Determining directory contents
echo "ls -l:" 1>"/export/bigdata/hadoop/logs/userlogs/application_1749212209307_0015/container_e16_1749212209307_0015_01_000002/directory.info"
ls -l 1>>"/export/bigdata/hadoop/logs/userlogs/application_1749212209307_0015/container_e16_1749212209307_0015_01_000002/directory.info"
echo "find -L . -maxdepth 5 -ls:" 1>>"/export/bigdata/hadoop/logs/userlogs/application_1749212209307_0015/container_e16_1749212209307_0015_01_000002/directory.info"
find -L . -maxdepth 5 -ls 1>>"/export/bigdata/hadoop/logs/userlogs/application_1749212209307_0015/container_e16_1749212209307_0015_01_000002/directory.info"
echo "broken symlinks(find -L . -maxdepth 5 -type l -ls):" 1>>"/export/bigdata/hadoop/logs/userlogs/application_1749212209307_0015/container_e16_1749212209307_0015_01_000002/directory.info"
find -L . -maxdepth 5 -type l -ls 1>>"/export/bigdata/hadoop/logs/userlogs/application_1749212209307_0015/container_e16_1749212209307_0015_01_000002/directory.info"
echo "Launching container"
exec /bin/bash -c "$JAVA_HOME/bin/java -Xms1024m -Xmx1024m -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintGCDateStamps -XX:+UseConcMarkSweepGC -Djava.io.tmpdir=$PWD/tmp me.wang.SampleExecutor abc 123 1>/export/bigdata/hadoop/logs/userlogs/application_1749212209307_0015/container_e16_1749212209307_0015_01_000002/stdout 2>/export/bigdata/hadoop/logs/userlogs/application_1749212209307_0015/container_e16_1749212209307_0015_01_000002/stderr "
